#include <iostream>
#include <cstring>
#include <memory>
#include "Task.hpp"
// #include "threadPool_V1.hpp"
// #include "threadPool_V2.hpp"
// #include "threadPool_V3.hpp"
#include "threadPool_V4.hpp"

using namespace std;

int main()
{
    // ThreadPool<TaskCalc<int>>::GC gc;
    //智能指针
    // unique_ptr<ThreadPool<TaskCalc<int>>> tp(new ThreadPool<TaskCalc<int>>(20));
    // tp->init();
    // tp->start();
    // tp->check();

    int n = 0;
    while(true)
    {
        //派发任务
        int x = rand() % 100;
        int y = rand() % 100;

        const char *ps = "+-*/%";
        char op = ps[rand() % strlen(ps)];

        ThreadPool<TaskCalc<int>>::GetInstace()->pushTask(TaskCalc<int>(x, y, op));
        // ThreadPool<TaskCalc<int>>::_gc.Print();

        // tp->pushTask(TaskCalc<int>(x, y, op));
        sleep(1);

        if(n++ == 5)
            break;
    }

    return 0;
}